package com.qf.controller;

import com.qf.entity.Goods;
import com.qf.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//商品  控制器层

@RestController
@RequestMapping("/GoodsController")
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    /**
     * 通过商家的id去查询商家对应的商品
     * @param m_id
     * @return
     */
    @RequestMapping("/selGoodsByMerchantId/{m_id}")
    public List<Goods> selGoodsByMerchantId(@PathVariable("m_id") Integer m_id){
        List<Goods>  goodList= goodsService.selGoodsByMerchantId(m_id);
        for (Goods g:goodList ) {
            System.out.println("-----------------"+g);
        }
        return  goodList;
    }
    @RequestMapping("/selByGoodsId/{g_id}")
    public Goods selByGoodsId(@PathVariable("g_id") Integer g_id){
        Goods goods = goodsService.selByGoodsId(g_id);
        System.out.println("------------vvvvv2345678i-----"+goods);
        return  goods;
    }
}
